import { defineStore } from "pinia";

export const useUserStore = defineStore("user", () => {

    const user = ref({
        uid: "",
        userType: "",
        password: "",
        nickname: "",
        phoneNumber: "",
        gender: "",
        introduction: "",
        createTime: "",
        updateTime: ""
    })
    
    //setter
    const setUid = (uid) => {
        user.value.uid = uid
    }
    const setUserType = (userType) => {
        user.value.userType = userType
    }
    const setPassword = (password) => {
        user.value.password = password
    }
    const setNickname = (nickname) => {
        user.value.nickname = nickname
    }
    const setPhoneNumber = (phoneNumber) => {
        user.value.phoneNumber = phoneNumber
    }
    const setGender = (gender) => {
        user.value.gender = gender
    }
    const setIntroduction = (introduction) => {
        user.value.introduction = introduction
    }
    const setCreateTime = (createTime) => {
        user.value.createTime = createTime
    }
    const setUpdateTime = (updateTime) => {
        user.value.updateTime = updateTime
    }

    
    return { 
        user,
        setUid,
        setUserType,
        setPassword,
        setNickname,
        setPhoneNumber,
        setGender,
        setIntroduction,
        setCreateTime,
        setUpdateTime
    }

},
{
    persist: true//持久化存储
}
); 